package com.zcxy.fast.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;

import com.zcxy.fast.anotation.Log;
import com.zcxy.fast.bean.PageQuery;
import com.zcxy.fast.bean.Response;
import com.zcxy.fast.entity.SysDictItem;
import com.zcxy.fast.service.ISysDictItemService;
import com.zcxy.fast.vo.SysDictItemVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 平台-字典值Controller
 *
 * @author zcc
 * @email  860474958@qq.com
 * @date   2020-12-18 15:15:57
 */
@RestController
@RequestMapping("/api/sysDictItem")
@Api(tags = "平台-字典值管理")
@Slf4j
public class SysDictItemController {
    @Autowired
    private ISysDictItemService iSysDictItemService;

    @Log("获取平台-字典值数据--分页")
    @PostMapping(value = "/queryPageList")
    @ApiOperation(value = "获取(平台-字典值)分页数据列表", notes = "获取(平台-字典值)分页数据列表")
    public Response<IPage<SysDictItemVo>> queryPageList(@RequestBody PageQuery<SysDictItem> queryVo) {
        return Response.ok(iSysDictItemService.queryPageList(queryVo));
    }

    @Log("获取平台-字典值数据-列表")
    @PostMapping(value = "/queryList")
    @ApiOperation(value = "获取平台-字典值数据-列表", notes = "获取平台-字典值数据-列表")
    public Response<List<SysDictItemVo>> queryList(@RequestBody SysDictItem sysDictItem) {
        return Response.ok(iSysDictItemService.queryList( sysDictItem));
    }


    @Log("添加平台-字典值数据")
    @PostMapping(value = "/add")
    @ApiOperation(value = "添加平台-字典值数据", notes = "添加平台-字典值数据")
    public Response addSysDictItem(@RequestBody @Validated @NotNull SysDictItem queryVo) {
        iSysDictItemService.addSysDictItem(queryVo);
        return Response.ok();
    }


    @Log("修改平台-字典值数据")
    @PostMapping(value = "/update")
    @ApiOperation(value = "修改平台-字典值数据", notes = "修改平台-字典值数据")
    public Response updateSysDictItem(@RequestBody @Validated @NotNull SysDictItem queryVo) {
        iSysDictItemService.updateSysDictItem(queryVo);
        return Response.ok();
    }


    @Log(value = "批量删除平台-字典值")
    @ApiOperation("批量删除平台-字典值")
    @PostMapping("/dels")
    public Response deleteByIds(@RequestBody List<String> ids) {
        iSysDictItemService.removeAllSysDictItem(ids);
        return Response.ok();
    }

}
